<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/view/taglib/common.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>QuestionImport</title>
		<%@ include file="/WEB-INF/view/taglib/header.jsp" %>
		<%@ include file="/WEB-INF/view/taglib/easyui.jsp" %>
		<%@ include file="/WEB-INF/view/taglib/layer.jsp" %>
		<%@ include file="/WEB-INF/view/taglib/uedit.jsp" %>
		<%@ include file="/WEB-INF/view/taglib/uploadify.jsp" %>
	</head>
	<body>
	 	<div style="position:absolute;top:10px;left:20px;right:20px;bottom:10px;">
			<form id="dataForm" method="post">
				<div class="fitem">
					<ks:formTag table="em_question_import" column="REMARKS"/>
				</div>
				<div class="fitem">
					<ks:formTag table="em_question_import" column="LIBRARY_ID"/>
				</div>
				<div class="fitem">
					<ks:formTag table="em_question_import" column="FILE_NAME"/>无需填写
				</div>
				<div class="fitem">
					<ks:formTag table="em_question_import" column="FILE_PATH"/>无需填写
				</div>
				<div class="fitem">
					<ks:formTag table="em_question_import" column="MEMO"/>
				</div>
				<div class="fitem">
                	<label>请上传Excel试题文件</label>
	                <input id="fileUrl" type="hidden" name="fileUrl"/>
	                <!-- 自行编写上传附件模块 -->
					<div id="uploadfileQueue"></div>
					<input type="file" id="uploadify" name="uploadify"
					data-queueid="uploadfileQueue"
					data-filetypeexts="*.xls;*.xlsx"
					data-buttontext="请上传Excel试题文件" data-auto="true"
					data-multi="false" data-queuesizelimit="5"
					data-filesizelimit="15000KB" data-method="POST"
					data-url="upload\" />
					<input id="showname" value="" type="text" style="border:none;outline:none;width:500px;" />
				</div>
				<a href="/docs/download/选择题导入模版V1.xlsx">点击下载模板</a>
				<input id="id" name="id" type="hidden"/>
			</form>
		</div>
		<script type="text/javascript">
			var loadi,url,index = parent.layer.getFrameIndex(window.name);
			$(document).ready(function() {
				var row = parent.$('#dataList').datagrid('getSelected');
				url = '${ctx}/exam/questionImport/save';
				
				// 添加上传附件组件渲染及设置回调函数
				mineUpload($("#uploadify"), "${ctx}", "afterMineUpload");
				
				if(row != null) {
					$('#dataForm').form('load', row);
					url = '${ctx}/exam/questionImport/update';
				}
			});
			
			//上传附件成功回调函数
		    function afterMineUpload(file, uf, message) {
		    	$("input[name='filePath']").val(uf.url +"/"+ uf.realname); //给隐藏输入框赋值
		    	$("input[name='fileName']").val(file.name);
		    	$("#showname").val(file.name+'，上传成功，请点击保存');
		    	
			}
			
			function submitInfo() {
				$('#dataForm').form('submit',{
					url: url,
					onSubmit: function(param) {
						if($(this).form('validate')) {
							loadi = parent.layer.load(2, {shade: layerLoadShade,time: layerLoadMaxTime});
							return true;
						} else {
							return false;
						}
					},
					success: function(data) {
						parent.layer.close(loadi);
						cleanErrMsg();
						var data = eval('(' + data + ')');
						if (data.success==TRUE) {
							parent.$.questionImport.reloadData();
							parent.layer.msg("操作成功！", {offset: layerMsgOffset,icon: 6,shift: 8,time: layerMsgTime});
							parent.layer.close(index);
						} else {
							renderErrMsg(data.message);
						}
					}
				});
			}
		</script>
	</body>
</html>
